namespace WGT
{
    public static class AttrUtil
    {
        public static string ToVisible(this bool b)
        {
            string state = "";
            if (!b) state = "none";
            return string.Format(" style.display='{0}'", state).ToLower();
        }

        public static string ToEnabled(this bool b)
        {
            return string.Format(" disabled={0}", b).ToLower();
        }

        public static string ToChecked(this bool b)
        {
            if (b) return " CHECKED";
            return string.Empty;
        }

        public static string ToSelected(this bool selected)
        {
            if (selected) return "SELECTED";
            return string.Empty;
        }

        public static string First(string[] attrs)
        {
            return attrs != null && attrs.Length > 0 ? attrs[0] : null;
        }

        public static string Second(string[] attrs)
        {
            return attrs != null && attrs.Length > 1 ? attrs[1] : null;
        }
    }
}